package com.youlai.quarkus.system.converter;

import com.youlai.quarkus.system.model.entity.SysDept;
import com.youlai.quarkus.system.model.form.DeptForm;
import com.youlai.quarkus.system.model.vo.DeptVO;
import jakarta.enterprise.context.ApplicationScoped;

/**
 * @author csp 2024-09-03
 */
@ApplicationScoped
public class DeptConverter {

    public DeptForm entity2Form(SysDept entity) {
        if (entity == null) {
            return null;
        } else {
            DeptForm deptForm = new DeptForm();
            deptForm.setId(entity.getId());
            deptForm.setName(entity.getName());
            deptForm.setParentId(entity.getParentId());
            deptForm.setStatus(entity.getStatus());
            deptForm.setSort(entity.getSort());
            return deptForm;
        }
    }

    public DeptVO entity2Vo(SysDept entity) {
        if (entity == null) {
            return null;
        } else {
            DeptVO deptVO = new DeptVO();
            deptVO.setId(entity.getId());
            deptVO.setParentId(entity.getParentId());
            deptVO.setName(entity.getName());
            deptVO.setSort(entity.getSort());
            deptVO.setStatus(entity.getStatus());
            deptVO.setCreateTime(entity.getCreateTime());
            deptVO.setUpdateTime(entity.getUpdateTime());
            return deptVO;
        }
    }

    public SysDept form2Entity(DeptForm deptForm) {
        if (deptForm == null) {
            return null;
        } else {
            SysDept sysDept = new SysDept();
            sysDept.setId(deptForm.getId());
            sysDept.setName(deptForm.getName());
            sysDept.setParentId(deptForm.getParentId());
            sysDept.setSort(deptForm.getSort());
            sysDept.setStatus(deptForm.getStatus());
            return sysDept;
        }
    }
}
